﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ManageBanking.Models
{
    
    public class HistoryUserModels
    {
        private OnlineBankingDataContext olbk = new OnlineBankingDataContext();

        public List<InforTransferSent> ListTransferSent(string idaccount, out int totalTransferSent)
        {
            totalTransferSent = olbk.InforTransferSents.Where(ac=>ac.IdAccountFrom.Trim().Equals(idaccount.Trim()) ).Count();
            return olbk.InforTransferSents.Where(ac => ac.IdAccountFrom.Trim().Equals(idaccount.Trim())).OrderByDescending(a => a.DateCreate).ToList();
        }



        public List<InforTransferReceive> ListTransferReceive(string idaccount, out int totalTransferReceive)
        {
            totalTransferReceive = olbk.InforTransferReceives.Where(ac => ac.IdAccountTo.Trim().Equals(idaccount.Trim())).Count();
            return olbk.InforTransferReceives.Where(ac => ac.IdAccountTo.Trim().Equals(idaccount.Trim())).ToList();
        }



        public List<Cheque> ListCheque(string idaccount, out int totalCheque)
        {
            totalCheque = olbk.Cheques.Where(ac=>ac.IdAccount.Trim().Equals(idaccount.Trim())).Count();
            return olbk.Cheques.Where(ac => ac.IdAccount.Trim().Equals(idaccount.Trim())).ToList();
        }



        public List<Deposit_With> ListDeposit_Withdraw(string idaccount, out int totalDepositWithdraw)
        {
            totalDepositWithdraw = olbk.Deposit_Withs.Where(ac => ac.IdAccount.Trim().Equals(idaccount.Trim())).Count();
            return olbk.Deposit_Withs.Where(ac => ac.IdAccount.Trim().Equals(idaccount.Trim())).ToList();
        }

        public InformationAccount InforAcc(string idaccount)
        {
            return olbk.InformationAccounts.Where(ia => ia.IdAccount.Trim().Equals(idaccount.Trim())).First();
        }

    }
}
